package net.lainiao.reptile;

import cn.wanghaomiao.seimi.core.Seimi;

/**
 * Created by Administrator on 2017/1/9.
 */
public class ReptileService{
    public static volatile int status = 0;
    private static  Seimi seimi = new Seimi();
    public static synchronized String start() {
        if (status == 0) {
            status = 1;
            FilterHelper.initHashMap();
            startInfo();
            return "服务启动成功";
        }
        return "服务已经在运行";
    }

    private static void startInfo() {
        seimi.goRun(false,"reptileCrawlers");
    }

    private static void stopInfn() {
        seimi.stop();
    }

    public static synchronized String stop() {
        if (status != 0) {
            status = 0;
            stopInfn();
            return "服务停止成功";
        }
        return "服务早前已经被终止";
    }
}
